

<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge">
		<title>账号绑定</title>
		<link type="text/css" rel="styleSheet" href="__CDN__/assets/css/register.css" />
		<script src="https://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
		<script src="__CDN__/assets/js/md5.js"></script>
	</head>

	<body>
		<div class="container">
			<div class="title">
				账号绑定
			</div>
			<div class="input-container">
				<div class="item">
					<input type="text" id="account" value="" placeholder="请输入手机号" />
				</div>
				<div class="item">
					<input type="password" id="password" value="" placeholder="请输入密码" />
				</div>
				<div class="item" style="border:0;margin-bottom:15px;">
					<input type="button" id="bind"  value="立即绑定" style="padding:0;height:50px;background: #FB6171;border-radius: 25px;font-size: 16px;color:#fff" />
				</div>
			</div>
			<div class="header">
				<img src="__CDN__/assets/img/logo.png" style="width: 45px;height: 45px;" />
			</div>
		</div>
		<div id="showtoast" class="showtoast">
			<div id="msg" class="msg"></div>
		</div>
		<script>
			var url = '{$url}';

			function showtoast(obj) {
				$('#showtoast').css('display', 'flex')
				$('#msg').html(obj.msg)
				var time = obj.dur ? obj.dur : 1500
				setTimeout(() => {
					$('#showtoast').css('display', 'none')
					$('#msg').html('')
				}, time)
			}

			$(function() {
				$('#bind').click(function() {
					var account = $('#account').val()
					var password = $('#password').val()
					if (!account) {
						showtoast({
							msg: '请输入手机号码'
						})
						return;
					}
					if (!(/^1[34578]\d{9}$/.test(account))) {
						showtoast({
							msg: '手机格式不正确'
						})
						return;
					}
					
					if (!password) {
						showtoast({
							msg: '请输入密码'
						})
						return;
					}
					
					$.ajax({
						type: "POST",
						url: url,
						data: {
							account: account,
							password: password,
						},
						dataType: "json",
						success: function(res) {
							if (res.code) {
								showtoast({
									msg: '绑定成功'
								})
								//downapp()
							} else {
								showtoast({
									msg: res.msg
								})
							}
						},
						fail: function(res) {
							showtoast({
								msg: res.msg
							})
						}
					});
				})

			})
		</script>
	</body>

</html>
